package one.stand.controller;

import one.stand.model.ResultModel;
import one.stand.model.RoyaltyRecordModel;
import one.stand.request.*;
import one.stand.response.CompanyRecruitResponse;
import one.stand.response.DynamicResponse;
import one.stand.response.UserCommonResponse;
import one.stand.service.UserService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 个人中心
 * @author Administrator
 */
@RestController
@RequestMapping("/personal")
public class PersonalController extends BaseController {

    /**
     * 添加收藏
     */
    @PostMapping("/addCollection")
    public ResultModel addCollection(@RequestBody CollectionRequest request) {
        return personalService.addCollection(request);
    }

    /**
     * 取消收藏
     */
    @PostMapping("/delCollection")
    public ResultModel delCollection(@RequestBody CollectionRequest request) {
        return personalService.delCollection(request);
    }

    /**
     * 查询收藏
     */
    @PostMapping("/getCollection")
    public ResultModel getCollection(@RequestBody CollectionRequest request) {
        return personalService.getCollection(request);
    }

    /**
     * 判断是否已经收藏
     */
    @PostMapping("/getIsCollection")
    public ResultModel<Integer> getIsCollection(@RequestBody CollectionRequest request) {
        return personalService.getIsCollection(request);
    }

    /**
     * 添加我的地址
     */
    @PostMapping("/addAddress")
    public ResultModel addAddress(@RequestBody AddressRequest request) {
        return personalService.addAddress(request);
    }

    /**
     * 修改我的地址
     */
    @PostMapping("/updAddress")
    public ResultModel updAddress(@RequestBody AddressRequest request) {
        return personalService.updAddress(request);
    }

    /**
     * 删除我的地址
     */
    @PostMapping("/delAddress")
    public ResultModel delAddress(@RequestBody AddressRequest request) {
        return personalService.delAddress(request);
    }

    /**
     * 我的地址设置为默认值
     */
    @PostMapping("/isdefult")
    public ResultModel isdefult(@RequestBody AddressRequest request) {
        return personalService.isdefult(request);
    }

    /**
     * 查询我的地址
     */
    @PostMapping("/getAddress")
    public ResultModel getAddress(@RequestBody TokenRequest request) {
        return personalService.getAddress(request);
    }

    /**
     * 查询公司信息
     */
    @PostMapping("/getCompanyAllInfo")
    public ResultModel getCompanyAllInfo(@RequestBody CompanyRequest request) {
        return personalService.getCompanyAllInfo(request);
    }

    /**
     * 查询公司动态
     */
    @PostMapping("/getDynamicInfo")
    public ResultModel<List<DynamicResponse>> getDynamicInfo(@RequestBody DynamicRequest request) {
        return  personalService.getDynamicInfo(request);
    }

    /**
     * 给动态/文章点赞
     */
    @PostMapping("/doDynamicThumbs")
    public ResultModel doDynamicThumbs(@RequestBody DynamicRequest request) {
        return personalService.doDynamicThumbs(request);
    }

    /**
     * 查询所有评论/回复
     */
    @PostMapping("/selectComment")
    public ResultModel selectComment(@RequestBody CommentRequest request) {
        return personalService.selectComment(request);
    }

    /**
     * 用户评论/回复
     */
    @PostMapping("/doComment")
    public ResultModel doComment(@RequestBody CommentRequest request) {
        return personalService.doComment(request);
    }

    /**
     * 用户删除评论
     */
    @PostMapping("/delComment")
    public ResultModel delComment(@RequestBody CommentRequest request) {
        return personalService.delComment(request);
    }

    /**
     * 查询公司官网
     */
    @PostMapping("/getWebsiteInfo")
    public ResultModel getWebsiteInfo(@RequestBody WebsiteRequest request) {
        return personalService.getWebsiteInfo(request);
    }

    /**
     * 查询公司招聘信息
     */
    @PostMapping("/getCompanyRecruit")
    public ResultModel<List<CompanyRecruitResponse>> getCompanyRecruit(@RequestBody CompanyRecruitRequest request) {
        return personalService.getCompanyRecruit(request);
    }

    /**
     * 用户提交需求信息
     */
    @PostMapping("/addDemand")
    public ResultModel addDemand(@RequestBody DemandRequest request) {
        return personalService.addDemand(request);
    }

    /**
     * 用户保存formId
     */
    @PostMapping("/addFormId")
    public ResultModel<Integer> addFormId(@RequestBody UserRequest request) {
        return userService.addFormId(request);
    }

    /**
     * 发送给crm端的员工
     *
     * @param sendUserId 发送人userId
     * @param receiveUserId 接收人userId
     * @param text 聊天消息提示內容
     * @param type 0未读消息提示，1联系方式提示
     * @return
     */
    @PostMapping("/unreadMessage")
    public ResultModel unreadMessage(@RequestParam(value="sendUserId") Integer sendUserId,@RequestParam(value="receiveUserId") Integer receiveUserId, @RequestParam(value="text") String text, @RequestParam(value="type") Integer type) {
        return userService.unreadMessage(sendUserId, receiveUserId, text, type);
    }

    /**
     * 佣金列表
     */
    @PostMapping("/selectRoyaltyRecord")
    public ResultModel<Map<String, Object>> selectRoyaltyRecord(@RequestBody RoyaltyRecordRequest request) {
        return userService.selectRoyaltyRecord(request);
    }

    /**
     * 提现操作
     */
    @PostMapping("/doCash")
    public ResultModel<Boolean> doCash(@RequestBody RoyaltyRecordRequest request) {
        return userService.doCash(request);
    }

    /**
     * 查询用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/selectUserCommonList")
    public ResultModel<List<UserCommonResponse>> selectUserCommonList(@RequestBody UserCommonRequest request) {
        return userService.selectUserCommonList(request);
    }

    /**
     * 新增/修改用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/insertUserCommonList")
    public ResultModel<Boolean> insertUserCommonList(@RequestBody UserCommonRequest request) {
        return userService.insertUserCommonList(request);
    }

    /**
     * 删除用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/delUserCommonList")
    public ResultModel<Boolean> delUserCommonList(@RequestBody UserCommonRequest request) {
        return userService.delUserCommonList(request);
    }

    /**
     * 上下移动用户常用语（3.2版本迭代）
     *
     * @param request
     * @return
     */
    @PostMapping("/moveUserCommon")
    public ResultModel<Boolean> moveUserCommon(@RequestBody UserCommonRequest request) {
        return userService.moveUserCommon(request);
    }
}
